home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performExtendSurface.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  17.5 KB  |  684 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  22 April 1997
  22. //  Author:         sjt
  23. //
  24. //  Description:
  25. //        Initialize the option values.
  26. //
  27. //  Input Arguments:
  28. //      int action
  29. //        0 - just execute the extend surface operation
  30. //        1 - show the option box dialog
  31. //        2 - drag to shelf
  32. //
  33. //  Return Value:
  34. //      None.
  35. //
  36. //    Notes:
  37. //        In the future this can be modified to include extend to object
  38. //
  39. global proc extendSurfaceEnableBoth( string $joinWidget,
  40.                                      string $directionWidget,
  41.                                      string $endWidget,
  42.                                      string $originalsWidget,
  43.                                      int $priorityEnd )
  44. {
  45.     int $enable;
  46.     if( $priorityEnd ) {
  47.         int $end = `radioButtonGrp -q -select $endWidget`;
  48.         int $dir = `radioButtonGrp -q -select $directionWidget`;
  49.  
  50.         $enable = ((3 != $end) && (3 != $dir));
  51.         checkBoxGrp -edit -enable $enable $joinWidget;
  52.  
  53.         $enable = `checkBoxGrp -q -value1 $joinWidget`;
  54.         checkBoxGrp -edit -enable $enable $originalsWidget;
  55.     }
  56.     else {
  57.         int $join = `checkBoxGrp -q -value1 $joinWidget`;
  58.         $enable = $join;
  59.  
  60.         radioButtonGrp -edit -enable3 $enable $endWidget;
  61.         radioButtonGrp -edit -enable3 $enable $directionWidget;
  62.         checkBoxGrp -edit -enable $enable $originalsWidget;
  63.     }
  64. }
  65.  
  66. proc setOptionVars(int $forceFactorySettings)
  67. {
  68.     //    Extension Type ( 0 = linear or 1 = circular or 2 = extrapolate ).
  69.     //    Used only if extend method is 0
  70.     //    Default = 0 = linear.  Circular currently disabled.
  71.     //
  72.     if ($forceFactorySettings || !`optionVar -exists extendSurfaceType`) {
  73.         optionVar -intValue extendSurfaceType 0;
  74.     }
  75.  
  76.     //    Extend Distance.
  77.     //    Used only if extend method is 0
  78.     //    Default = 1.00
  79.     //
  80.     if ($forceFactorySettings || !`optionVar -exists extendSurfaceDistance`) {
  81.         optionVar -floatValue extendSurfaceDistance 1.0;
  82.     }
  83.  
  84.     //    Extend Direction ( 0 = U, 1 = V, 2 = both)
  85.     //    Default = 0
  86.     //
  87.     if ($forceFactorySettings || !`optionVar -exists extendSurfaceDirection`) {
  88.         optionVar -floatValue extendSurfaceDirection 0;
  89.     }
  90.  
  91.     //    Extend Start ( 1 = start or 0 = end, 2 = both )
  92.     //    Default = 0
  93.     //
  94.     if ($forceFactorySettings || !`optionVar -exists extendSurfaceSide`) {
  95.         optionVar -intValue extendSurfaceSide 0;
  96.     }
  97.  
  98.     //    Extend Join ( on = join or off = do not join )
  99.     //    Default = ON
  100.     //
  101.     if ($forceFactorySettings || !`optionVar -exists extendSurfaceJoin`) {
  102.         optionVar -intValue extendSurfaceJoin 1;
  103.     }
  104.  
  105.     //  keep original (for in place operations is on-1 or off-0 )
  106.     //    Used only when joining
  107.     /// Default = 0
  108.     //
  109.     if ($forceFactorySettings || !`optionVar -exists extendSurfaceKeepOriginal`) {
  110.         optionVar -intValue extendSurfaceKeepOriginal 0;
  111.     }
  112.  
  113. }
  114.  
  115. //
  116. //  Procedure Name:
  117. //      extendSurfaceSetup
  118. //
  119. //  Description:
  120. //        Update the state of the option box UI to reflect the extend surface
  121. //        option values.
  122. //
  123. //  Input Arguments:
  124. //      parent               - Top level parent layout of the option box UI.
  125. //                             Required so that UI object names can be 
  126. //                             successfully resolved.
  127. //
  128. //        forceFactorySettings - Whether the option values should be set to
  129. //                             default values.
  130. //
  131. //  Return Value:
  132. //      None.
  133. //
  134. global proc extendSurfaceSetup( string $parent,
  135.                                 int $forceFactorySettings,
  136.                                 string $goToTool )
  137. {
  138.     //    Retrieve the option settings
  139.     //
  140.     setOptionVars($forceFactorySettings);
  141.     extendSurfaceToolSetup( $forceFactorySettings, $goToTool );
  142.  
  143.     setParent $parent;
  144.  
  145.     //    Query the optionVar's and set the values into the controls.
  146.  
  147.     // extend distance
  148.     floatSliderGrp -edit
  149.         -value `optionVar -query extendSurfaceDistance`
  150.         extendSurfaceDistanceSlider;
  151.  
  152.     // extend type
  153.     int $extendType = `optionVar -query extendSurfaceType`;
  154.     int $extendTypeBtn = ($extendType + 2)/2;
  155.     radioButtonGrp -edit
  156.         -select $extendTypeBtn
  157.         extendSurfaceTypeBtn;
  158.  
  159.     // extend start and join
  160.     //
  161.     int $join = `optionVar -query extendSurfaceJoin`;
  162.     int $start = `optionVar -query extendSurfaceSide`;
  163.     int $dir = `optionVar -query extendSurfaceDirection`;
  164.  
  165.     // convert from value to button number
  166.     // ( 1 = start or 0 = end, 2 = both )
  167.     switch( $start ) {
  168.       case 0:
  169.         $start = 2;
  170.         break;
  171.       case 1:
  172.         $start = 1;
  173.         break;
  174.       case 2:
  175.       default:
  176.         $start = 3;
  177.         break;
  178.     }
  179.  
  180.     radioButtonGrp -edit
  181.         -select $start
  182.         extendSurfaceSideBtn;
  183.  
  184.     radioButtonGrp -edit
  185.         -select ($dir+1)
  186.         extendSurfaceDirectionBtn;
  187.  
  188.     // Extend join
  189.     //
  190.     checkBoxGrp -edit
  191.         -value1 $join
  192.         extendSurfaceJoinBox;
  193.  
  194.     // Keep original.
  195.     //
  196.     checkBoxGrp -edit
  197.         -value1 `optionVar -query extendSurfaceKeepOriginal`
  198.         -enable ($join && (3 != $start))
  199.         extendSurfaceKeepOriginalBox;
  200.  
  201.     extendSurfaceEnableBoth( "extendSurfaceJoinBox",
  202.                              "extendSurfaceDirectionBtn",
  203.                              "extendSurfaceSideBtn",
  204.                              "extendSurfaceKeepOriginalBox",
  205.                              0 );
  206.  
  207.     if( "" != $goToTool ) { 
  208.         checkBoxGrp -e -v1 `scriptCtx -q -euc $goToTool`
  209.           scriptToolExtraWidget;
  210.         checkBoxGrp -e -v2 `scriptCtx -q -lac $goToTool`
  211.           scriptToolExtraWidget;
  212.     }
  213. }
  214.  
  215. //
  216. //  Procedure Name:
  217. //      extendSurfaceCallback
  218. //
  219. //  Description:
  220. //        Update the option values with the current state of the option box UI.
  221. //
  222. //  Input Arguments:
  223. //      parent - Top level parent layout of the option box UI.  Required so
  224. //               that UI object names can be successfully resolved.
  225. //
  226. //        doIt   - Whether the command should execute.
  227. //
  228. //  Return Value:
  229. //      None.
  230. //
  231. global proc extendSurfaceCallback(string $parent, int $doIt, string $goToTool)
  232. {
  233.     if( "" != $goToTool ) {
  234.         optionVar -iv extendSurfaceEuc `scriptCtx -q -euc $goToTool`;
  235.         optionVar -iv extendSurfaceLac `scriptCtx -q -lac $goToTool`;
  236.     }
  237.     setParent $parent;
  238.  
  239.     //    Set the optionVar's from the control values, and then
  240.     //    perform the command.
  241.  
  242.     int $extendType, $extendTypeBtn;
  243.     $extendTypeBtn = `radioButtonGrp -query -select extendSurfaceTypeBtn`;
  244.     $extendType = 2 * $extendTypeBtn - 2;
  245.     optionVar -intValue extendSurfaceType $extendType;
  246.  
  247.     // extend distance
  248.     //
  249.     optionVar -floatValue extendSurfaceDistance
  250.         `floatSliderGrp -query -value extendSurfaceDistanceSlider`;
  251.  
  252.     // Start or end or both
  253.     // ( 1 = start or 0 = end, 2 = both )
  254.     int $start = `radioButtonGrp -query -select extendSurfaceSideBtn`;
  255.  
  256.     // convert from button number to value
  257.     switch( $start ) {
  258.       case 1:
  259.         $start = 1;
  260.         break;
  261.       case 2:
  262.         $start = 0;
  263.         break;
  264.       case 3:
  265.       default:
  266.         $start = 2;
  267.         break;
  268.     }
  269.     optionVar -intValue extendSurfaceSide $start;
  270.  
  271.     int $dir = `radioButtonGrp -query -select extendSurfaceDirectionBtn` - 1;
  272.     optionVar -intValue extendSurfaceDirection $dir;
  273.  
  274.     // Join
  275.     //
  276.     optionVar -intValue extendSurfaceJoin 
  277.         `checkBoxGrp -query -value1 extendSurfaceJoinBox`;
  278.  
  279.     // Keep original.
  280.     //
  281.     optionVar -intValue extendSurfaceKeepOriginal
  282.         `checkBoxGrp -query -value1 extendSurfaceKeepOriginalBox`;
  283.  
  284.     if (1 == $doIt) {
  285.         performExtendSurface( 0, $goToTool ); 
  286.         string $tmpCmd = "performExtendSurface( 0, \"" + $goToTool + "\")";
  287.         addToRecentCommandQueue $tmpCmd "Extend Surfaces";
  288.     }
  289.     else if( $doIt ) {
  290.         setToolTo $goToTool;
  291.     }
  292. }
  293.  
  294. //
  295. //  Procedure Name:
  296. //      createExtendSurfaceUI
  297. //
  298. //  Description:
  299. //      Fill the contents of the option box for extendSurface command.
  300. //
  301. //  Input Arguments:
  302. //      The name of the parent layout.
  303. //
  304. //  Return Value:
  305. //      None.
  306. //
  307. proc createExtendSurfaceUI(string $parent, int $inTheTool, string $goToTool)
  308. {
  309.     setParent $parent;
  310.  
  311.     // Currently, no circular extension:
  312.         radioButtonGrp -label "Extension Type"
  313.             -numberOfRadioButtons 2
  314.             -label1 "Tangent" -da1 0
  315.             -label2 "Extrapolate" -da2 2
  316.             extendSurfaceTypeBtn;
  317.  
  318.         floatSliderGrp -label "Distance"
  319.             -field true
  320.             -min 0.0
  321.             -max 10.0
  322.             extendSurfaceDistanceSlider;
  323.  
  324.     separator;
  325.  
  326.     string $endWidget = `radioButtonGrp -label "Extend Side"
  327.         -numberOfRadioButtons 3
  328.         -label1 "Start" -da1 1 -enable1 1
  329.         -label2 "End" -da2 0 -enable2 1 
  330.         -label3 "Both" -da3 0 -enable3 1
  331.         extendSurfaceSideBtn`;
  332.  
  333.     string $directionWidget = `radioButtonGrp -label "Extend Direction"
  334.         -numberOfRadioButtons 3
  335.         -label1 "U" -da1 1 -enable1 1
  336.         -label2 "V" -da2 2 -enable2 1 
  337.         -label3 "Both" -da3 3 -enable3 1
  338.         extendSurfaceDirectionBtn`;
  339.  
  340.     separator;
  341.  
  342.     string $joinWidget = `checkBoxGrp -label ""
  343.         -numberOfCheckBoxes 1
  344.         -label1 "Join to Original"
  345.         extendSurfaceJoinBox`;
  346.  
  347.     string $originalsWidget = `checkBoxGrp -label ""
  348.         -numberOfCheckBoxes 1
  349.         -label1 "Keep Original"
  350.         extendSurfaceKeepOriginalBox`;
  351.  
  352.     radioButtonGrp -edit
  353.         -onCommand1 (
  354.                 "extendSurfaceEnableBoth"
  355.                 + " " + $joinWidget
  356.                 + " " + $directionWidget
  357.                 + " " + $endWidget
  358.                 + " " + $originalsWidget + " 1;"
  359.             )
  360.         -onCommand2 (
  361.                 "extendSurfaceEnableBoth"
  362.                 + " " + $joinWidget
  363.                 + " " + $directionWidget
  364.                 + " " + $endWidget
  365.                 + " " + $originalsWidget + " 1;"
  366.             )
  367.         -onCommand3 (
  368.                 "extendSurfaceEnableBoth"
  369.                 + " " + $joinWidget
  370.                 + " " + $directionWidget
  371.                 + " " + $endWidget
  372.                 + " " + $originalsWidget + " 1;"
  373.             )
  374.         $endWidget;
  375.  
  376.     radioButtonGrp -edit
  377.         -onCommand1 (
  378.                 "extendSurfaceEnableBoth"
  379.                 + " " + $joinWidget
  380.                 + " " + $directionWidget
  381.                 + " " + $endWidget
  382.                 + " " + $originalsWidget + " 1;"
  383.             )
  384.         -onCommand2 (
  385.                 "extendSurfaceEnableBoth"
  386.                 + " " + $joinWidget
  387.                 + " " + $directionWidget
  388.                 + " " + $endWidget
  389.                 + " " + $originalsWidget + " 1;"
  390.             )
  391.         -onCommand3 (
  392.                 "extendSurfaceEnableBoth"
  393.                 + " " + $joinWidget
  394.                 + " " + $directionWidget
  395.                 + " " + $endWidget
  396.                 + " " + $originalsWidget + " 1;"
  397.             )
  398.         $directionWidget;
  399.  
  400.     checkBoxGrp -edit
  401.         -onCommand (
  402.                 "extendSurfaceEnableBoth"
  403.                 + " " + $joinWidget
  404.                 + " " + $directionWidget
  405.                 + " " + $endWidget
  406.                 + " " + $originalsWidget + " 0;"
  407.             )
  408.         -offCommand (
  409.                 "extendSurfaceEnableBoth"
  410.                 + " " + $joinWidget
  411.                 + " " + $directionWidget
  412.                 + " " + $endWidget
  413.                 + " " + $originalsWidget + " 0;"
  414.             )
  415.         $joinWidget;
  416.  
  417.     if( $inTheTool ) {
  418.         separator;
  419.         checkBoxGrp -ncb 2 -l "Tool Behavior"
  420.           -l1 "Exit on Completion"
  421.           -v1 off
  422.           -on1 ("scriptCtx -e -euc true " + $goToTool)
  423.           -of1 ("scriptCtx -e -euc false " + $goToTool)
  424.  
  425.           -l2 "Auto Completion"
  426.           -v2 on
  427.           -on2 ("scriptCtx -e -lac true " + $goToTool)
  428.           -of2 ("scriptCtx -e -lac false " + $goToTool)
  429.           scriptToolExtraWidget;
  430.     }
  431. }
  432.  
  433.  
  434. //
  435. //  Procedure Name:
  436. //      extendSurfaceOptions
  437. //
  438. //  Description:
  439. //        Construct the option box UI.  Involves accessing the standard option
  440. //        box and customizing the UI accordingly.
  441. //
  442. //  Input Arguments:
  443. //      None.
  444. //
  445. //  Return Value:
  446. //      None.
  447. //
  448. proc extendSurfaceOptions( int $inTheTool, string $goToTool )
  449. {
  450.     //    Name of the command for this option box.
  451.     //
  452.     string $commandName = "extendSurface";
  453.  
  454.     //    Build the option box actions.
  455.     //
  456.     string $callback = ($commandName + "Callback");
  457.     string $setup = ($commandName + "Setup");
  458.  
  459.     global string $gOptionBoxActionToolItem;
  460.     $gOptionBoxActionToolItem = "modelWithToolExtendSurface";
  461.     global string $gOptionBoxActionToolItemCB;
  462.     $gOptionBoxActionToolItemCB = "extendSurfaceToolScript 3";
  463.  
  464.     //  The value returned is the name of the layout to be used as
  465.     //    the parent for the option box UI.
  466.     //
  467.     string $layout = getOptionBox();
  468.     setParent $layout;
  469.     
  470.     //    Pass the command name to the option box.
  471.     //
  472.     //    Any default option box behavior based on the command name is set 
  473.     //    up with this call.  For example, updating the 'Help' menu item with
  474.     //    the name of the command.
  475.     //
  476.     setOptionBoxCommandName($commandName);
  477.     
  478.     //    Activate the default UI template so that the layout of this 
  479.     //    option box is consistent with the layout of the rest of the 
  480.     //    application.
  481.     //
  482.     setUITemplate -pushTemplate DefaultTemplate;
  483.  
  484.     //    Turn on the wait cursor.
  485.     //
  486.     waitCursor -state 1;
  487.  
  488.     //    RECOMMENDATION:  Place the UI in a scroll layout.  If the 
  489.     //    option box window is ever resized such that it's entire 
  490.     //    contents is not visible then the scroll bars provided by the
  491.     //    scroll layout will allow the user to access the hidden UI.
  492.     //
  493.     tabLayout -scr true -tv false;
  494.     
  495.     string $parent = `columnLayout -adjustableColumn 1`;
  496.     
  497.     //  Create the UI for the tab that is initially visible.
  498.     //
  499.     createExtendSurfaceUI($parent, $inTheTool, $goToTool);
  500.  
  501.     //    Turn off the wait cursor.
  502.     //
  503.     waitCursor -state 0;
  504.     
  505.     //    Deactivate the default UI template.
  506.     //
  507.     setUITemplate -popTemplate;
  508.  
  509.     //    Provide more descriptive labels for the buttons.  This is not 
  510.     //    necessary, but in some cases, for example, a button labelled 
  511.     //    'Create' may be more meaningful to the user than one labelled
  512.     //    'Apply'.
  513.     //
  514.     //  Disable those buttons that are not applicable to the option box.
  515.     //
  516.     //    Attach actions to those buttons that are applicable to the option
  517.     //    box.  Note that the 'Close' button has a default action attached 
  518.     //    to it that will hide the window.  If a a custom action is
  519.     //    attached to the 'Close' button then be sure to call the 'hide the
  520.     //    option box' procedure within the custom action so that the option
  521.     //    box is hidden properly.
  522.  
  523.     //    'ExtendSurface' button.
  524.     //
  525.     string $applyBtn = getOptionBoxApplyBtn();
  526.     if( $inTheTool ) {
  527.         button -edit -l "Extend Tool"
  528.             -command ($callback + " " + $parent + " 3 \"" + $goToTool + "\"")
  529.             $applyBtn;
  530.     }
  531.     else {
  532.         button -edit -l "Extend"
  533.             -command ($callback + " " + $parent + " 1 \"" + $goToTool + "\"")
  534.             $applyBtn;
  535.     }
  536.  
  537.     //    'Save' button.
  538.     //
  539.     string $saveBtn = getOptionBoxSaveBtn();
  540.     button -edit 
  541.         -command ($callback + " " + $parent + " 0 \"" +
  542.                   $goToTool + "\"; hideOptionBox")
  543.         $saveBtn;
  544.  
  545.     //    'Reset' button.
  546.     //
  547.     string $resetBtn = getOptionBoxResetBtn();
  548.     button -edit 
  549.         -command ($setup + " " + $parent + " 1 \"" + $goToTool + "\"")
  550.         $resetBtn;
  551.  
  552.     //    Set the option box title.
  553.     //
  554.     if( $inTheTool ) {
  555.         setOptionBoxTitle("Extend Surface Tool Options");
  556.     }
  557.     else {
  558.         setOptionBoxTitle("Extend Surface Options");
  559.     }
  560.  
  561.     //    Customize the 'Help' menu item text.
  562.     //
  563.     setOptionBoxHelpTag( "ExtendSurfaces" );
  564.  
  565.     //    Set the current values of the option box.
  566.     //
  567.     eval ($setup + " " + $parent + " 0 \"" + $goToTool + "\"");    
  568.     
  569.     //    Show the option box.
  570.     //
  571.     showOptionBox();
  572. }
  573.  
  574. //
  575. //  Procedure Name:
  576. //      extendSurfaceHelp
  577. //
  578. //  Description:
  579. //        Return a short description about this command.
  580. //
  581. //  Input Arguments:
  582. //      None.
  583. //
  584. //  Return Value:
  585. //      string.
  586. //
  587. proc string extendSurfaceHelp()
  588. {
  589.     return 
  590.     "  Command: extendSurface - extends a surface\n" +
  591.     "Selection: a surface ";    
  592. }
  593.  
  594. //
  595. //  Procedure Name:
  596. //      assembleCmd
  597. //
  598. //  Description:
  599. //        Construct the command that will apply the option box values.
  600. //
  601. //  Input Arguments:
  602. //      None.
  603. //
  604. //  Return Value:
  605. //      The extendSurface command string.
  606. //
  607. proc string assembleCmd()
  608. {
  609.     setOptionVars(false);
  610.  
  611.     // get the global history flag value
  612.     int $doHistory = `constructionHistory -q -tgl`;
  613.  
  614.     int $extendType = `optionVar -query extendSurfaceType`;
  615.     float $distance = `optionVar -query extendSurfaceDistance`;
  616.     int $side = `optionVar -query extendSurfaceSide`;
  617.     int $dir = `optionVar -query extendSurfaceDirection`;
  618.     int $join = `optionVar -query extendSurfaceJoin`;
  619.     int $replaceOriginal = !`optionVar -q extendSurfaceKeepOriginal`;
  620.  
  621.  
  622.     string $cmd = "doExtendSurfaceArgList 1 { ";
  623.  
  624.     $cmd = $cmd + "\"" + $doHistory + "\", ";
  625.     $cmd = $cmd + "\"" + "0" + "\", ";
  626.     $cmd = $cmd + "\"" + $extendType + "\", ";
  627.     $cmd = $cmd + "\"" + $distance + "\", ";
  628.     $cmd = $cmd + "\"" + $side + "\", ";
  629.     $cmd = $cmd + "\"" + $join + "\", ";
  630.     $cmd = $cmd + "\"" + $replaceOriginal + "\", ";
  631.     $cmd = $cmd + "\"" + $dir + "\" }";
  632.  
  633.     return $cmd;
  634. }
  635.  
  636. //
  637. //  Procedure Name:
  638. //      performExtendSurface
  639. //
  640. //  Description:
  641. //        Perform the optionBoxExample1 command using the corresponding 
  642. //        option values.  This procedure will also show the option box
  643. //        window if necessary as well as construct the command string
  644. //        that will invoke the optionBoxExample1 command with the current
  645. //        option box values.
  646. //
  647. //  Input Arguments:
  648. //      0 - Execute the command.
  649. //      1 - Show the option box dialog.
  650. //      2 - Return the command.
  651. //
  652. //  Return Value:
  653. //      None.
  654. //
  655. global proc string performExtendSurface(int $action, string $goToTool)
  656. {
  657.     int $inTheTool = false;
  658.     if( 3 == $action ) {
  659.         $action = 1;
  660.         $inTheTool = true;
  661.     }
  662.  
  663.     string $cmd = "";
  664.     switch ($action) {
  665.       case 0:
  666.         setOptionVars(false);
  667.         $cmd = `assembleCmd`;
  668.         eval($cmd);
  669.         break;
  670.  
  671.       case 1:
  672.         extendSurfaceOptions( $inTheTool, $goToTool );
  673.         break;
  674.  
  675.       case 2:
  676.       default:
  677.         setOptionVars (false);
  678.         $cmd = `assembleCmd`;
  679.         break;
  680.     }
  681.     return $cmd;
  682. }
  683.  
  684.